<?php

include_once($ROOT . "base.inc.php");

class PageController extends BaseController {
  var $tabString;
  var $songkey;
  var $songview;
  var $song;

  function PageController() {
	parent::__construct();

	$this->title = "Song Information";
	$this->section = "songs";

	$action = $this->getParameter("action");
	switch (strtoupper($action))
	{

		case "REFRESH" :
		case "VIEW TAB" :
			$this->parseForm();
		case "LOAD" :
			$id = $this->getParameter("id");

			if ($id != 0 && $id != "")
			{
				$song = SongLogic::load($id);
				$this->tabString = $song->info;
				$this->songkey = $song->key_played;
				$this->songview = 1; // All (Default)
			}

			if ($result = SongInfoLogic::getSongInformation($this->tabString,
				CodeLookupUtil::getValue("songkey",$this->songkey),
				CodeLookupUtil::getValue("songview", $this->songview)))
			{
				$this->title  = $result[0] . " by " . $result[1];
				$this->song   = $result[2];
			}
			else
			{
				$this->title  = "No Song Loaded";
				$this->song   = "";
			}
			break;
	}
  }

  function parseForm() {
	$this->tabString = $this->getParameter("tab");
	$this->songkey   = $this->getParameter("songkey");
	$this->songview  = $this->getParameter("songview");
  }

  function validate() {
	return (sizeof($this->errs) == 0);
  }

}



?>
